import "pkl:test"

class Numbers {
  xs: List<Int>
  ys: List<Int(this < 0)>
  zs: List<Int(this < 0)>(length >= 5)
}

class Numbers2 {
  // type constraint but no type parameter
  ys: List(every((it) -> it is Int(this < 0)))
}

res1 = new Numbers {
  xs = List(1, 2, 3)
  ys = List(-1, -2, -3)
  zs = List(-1, -2, -3, -4, -5)
}

res1b = new Numbers2 {
  ys = List(-1, -2, -3)
}

res2 = test.catch(() ->
  new Numbers {
    xs = "one"
  }.xs
)

res3 = test.catch(() ->
  new Numbers {
    xs = List("one")
  }.xs
)

res4 = test.catch(() ->
  new Numbers {
    ys = List(1, 2, 3)
  }.ys
)

res4b = test.catch(() ->
  new Numbers2 {
    ys = List(1, 2, 3)
  }.ys
)

res5 = test.catch(() ->
  new Numbers {
    zs = List(-1, -2, -3)
  }.zs
)
